﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Kiiro.Model;

using Microsoft.SharePoint;
using System.Drawing;

namespace Kiiro.SiteDefinition.KiiroPages
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load ( object sender, EventArgs e )
        {
            //setting tab index for the login controller will set the focus on the user name text box!            
            Page.SetFocus ( loginForm.FindControl ( "UserName" ) );

            recoveryMessage.Visible = false;
            loginForm.FailureText = "<h3>Your login attempt was not successful. Please try again.</h3>";

            recoveryMessage.Text = "<br /><h3 style='color:black;padding:0 10px;font-weight:bold;'>Enter your username and click 'Reset Password' to have a new password emailed to you.</h3>";
            recoveryMessage.Visible = true;
        }

        protected void lbForgotPassword_Click ( object sender, EventArgs e )
        {
            loginForm.Visible = false;
            recovery.Visible = true;
        }

        protected void lbPasswordReset_Click ( object sender, EventArgs e )
        {
            try
            {
                UserModel.ResetAndEmailPassword ( UserName.Text, SPContext.Current.Site.ID, SPContext.Current.Web.ServerRelativeUrl );
                recoveryMessage.Text = "<h3 style='color:green'>Thank you. Your new password will be emailed to you shortly.</h3>";
                lbPasswordReset.Enabled = false;
            }
            catch ( Exception ex )
            {
                recoveryMessage.Text = "<h3>" + ex.Message + "</h3>";
            }
        }
    }
}

/*************************************************************************
 * 
 * $Log: /Internal Projects/Kiiro/Kiiro.SiteDefinition/12/TEMPLATE/LAYOUTS/KiiroPages/Login.aspx.cs $
 * 
 * 7     1/12/10 12:45p Camerons
 * 
 * 6     18/11/09 6:20p Camerons
 * 
 * 1     18/11/09 3:31p Camerons
 * 
 * 5     17/08/09 11:07a Camerons
 * Added check-in comments section
 * 
 ************************************************************************/